﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.Common
{
    public partial class FindAllSort : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            dataBind();
            if (IsPostBack)
            {
                bindList();
            }
        }

        /// <summary>
        /// 数据绑定
        /// </summary>
        private void dataBind()
        {
            HZ.Supervise.IBLL.IBLL_ProcureCatalog pre = HZ.Supervise.BLLFactory.IBLL_ProcureCatalog();
            gvwSortList.AutoGenerateColumns = false;
            int outcount;
            gvwSortList.DataSource = pre.GetSort("", AspNetPager1.CurrentPageIndex,AspNetPager1.PageSize, out outcount);
            AspNetPager1.RecordCount = outcount;
            gvwSortList.DataBind();
        }


        /// <summary>
        /// 绑定List控件集合
        /// </summary>
        private void bindList()
        {
            string[] hosName = this.SortName.Value.Split(',');
            string[] hosId = this.SortId.Value.Split(',');
            this.ListSort.Items.Clear();
            for (int i = 0; i < hosName.Length; i++)
            {
                if (hosName[i].Equals(""))
                {
                    return;
                }
                ListItem item = new ListItem();
                item.Text = hosName[i];
                item.Value = hosId[i];
                this.ListSort.Items.Add(item);
            }
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            dataBind();
        }

    }
}
